package com.hong.chapter4;

import java.util.Optional;

/**
 * Created by hong on 2018/6/3.
 * jdk8 新特性 Optional
 */
public class ThreadSimpleAPI {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            Optional.of("hello").ifPresent(System.out::println);
            try {
                Thread.sleep(100_000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        },"t1");
        Optional.of(t1.getName()).ifPresent(System.out::println);
        Optional.of(t1.getId()).ifPresent(System.out::println);
        Optional.of(t1.getPriority()).ifPresent(System.out::println);

    }
}
